﻿<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:l="clr-namespace:UIControls;assembly=UIControls"
    Title="Sql Appifier" Height="486" Width="885" Icon="assets/db.ico">

    <Window.Resources>
        <ContextMenu x:Key="QueryListContextMenu">
            <MenuItem Header="_Edit" Click="EditQuery_Click">
                <MenuItem.Icon>
                    <Image Width="16" Height="16" Source="assets/edit.png"/>
                </MenuItem.Icon>
            </MenuItem>
            <Separator HorizontalAlignment="Left" Height="2" Width="auto"/>
            <MenuItem Name="QueryItemDelete" Header="_Delete" Click="QueryDelete_Click" >
                <MenuItem.Icon>
                    <Image Width="16" Height="16" Source="assets/delete.png"/>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>

        <ContextMenu x:Key="ConnectionListContextMenu">
            <MenuItem Name="ConnectionItemDelete" Header="_Delete" Click="ConnectionDelete_Click" >
                <MenuItem.Icon>
                    <Image Width="16" Height="16" Source="assets/delete.png"/>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>

    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Menu Grid.Row="0" IsMainMenu="True" Height="27" Name="FileMenu" HorizontalAlignment="Stretch" VerticalAlignment="Top" Width="auto" >
            <MenuItem Header="_File ">
                <MenuItem Header="_New Query" HorizontalAlignment="Left" Width="200" Click="NewQuery_Click" >
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="assets/create.png"/>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator HorizontalAlignment="Left" Height="1" Width="200"/>
                <MenuItem Header="_Add Connection" HorizontalAlignment="Left" Width="200" Click="NewConnection_Click">
                    <MenuItem.Icon>
                        <Image Width="16" Height="16" Source="assets/database.png"/>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator HorizontalAlignment="Left" Height="1" Width="200"/>
                <MenuItem Header="_Exit" HorizontalAlignment="Left" Width="200" Click="Exit_Click"/>
            </MenuItem>
        </Menu>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" MinWidth="200" />
                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Margin="10,10,10,10" Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="100"/>
                    <RowDefinition Height="5" />
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <ListBox Name="connectionList" Width="auto" Height="auto" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                         ItemsSource="{Binding connectionListSource}"
                         DisplayMemberPath="Name"
                         IsSynchronizedWithCurrentItem="True"
                         SelectionChanged="connectionList_SelectionChanged">

                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="ContextMenu" Value="{StaticResource ConnectionListContextMenu}"/>
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="ListBoxItem">
                                        <StackPanel>
                                            <ContentPresenter/>
                                            <Separator x:Name="Separator"/>
                                        </StackPanel>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
                <GridSplitter Grid.Row="1" Width="auto" Height="5" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
                <l:SearchTextBox Name="searchBox" Width="auto" Height="auto" Grid.Row="2" Margin="0,0,0,5" PlaceholderText="Search Queries..."/>
                <ListBox Name="queryList" Width="auto" Height="auto" Grid.Row="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                         ItemsSource="{Binding Path=queryListSource}"
                         DisplayMemberPath="Name"
                         IsSynchronizedWithCurrentItem="True" 
                         SelectionChanged="queryList_SelectionChanged">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="ContextMenu" Value="{StaticResource QueryListContextMenu}"/>

                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </Grid>
            <GridSplitter Grid.Column="1" Width="5" Height="auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            <Grid Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="auto" Width="auto"  Margin="10,10,10,10">
                <Border BorderBrush="Gray" BorderThickness="1" Height="auto" Width="auto" Background="Silver" HorizontalAlignment="Center" VerticalAlignment="Center" >
                    <Grid Name="QueryForm" Height="auto"  Width="auto" Background="GhostWhite" VerticalAlignment="Center" HorizontalAlignment="Center">
                        <Label>test</Label>
                        <TextBox>asdasd</TextBox>
                    </Grid>
                </Border>
            </Grid>
        </Grid>
    </Grid>
</Window>
